/**
 * Witontek.com.
 * Copyright (c) 2012-2018 All Rights Reserved.
 */
package test.closure.c2;

/**
 * 
 * @author Long
 * @version $Id: Closure.java, v 0.1 2018年4月20日 下午5:31:35  xiaolong.ma  Exp $
 */
public class Closure {
    public static void main(String[] args) {
        Closure closure = new Closure();
        for (int i = 1; i <= 10; i++) {
            System.out.println(closure.create(i).increment(i));
        }
    }

    class InnerClosure {
        InnerClosure(int initial) {
            this.initial = initial;
        }

        private final int initial;

        public int increment(int i) {
            return this.initial + i;
        }

        @Override
        public InnerClosure clone() {
            return this;
        }
    }

    public InnerClosure create(int initial) {
        return new InnerClosure(initial);
    }
}
